package modelo.conexao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

public class conexao {

    private String url;
    private String login;
    private String senha;
    private String driver;
    private Connection conexao;
    public Statement statement;

    public conexao() {

        this.driver = "org.postgresql.Driver";

        this.url = "jdbc:postgresql://localhost:5432/bdHotelaria";

        this.login = "postgres";

        this.senha = "postgres";

    }

    public void conectar() throws Exception {

        Class.forName(driver);
            conexao = DriverManager.getConnection(url, login, senha);
        statement= conexao.createStatement();
    }

    public void desconectar() throws Exception {
        this.getConexao().close();
    }

    public boolean isConectado() {
        try {
            return this.getConexao().isClosed();
        } catch (Exception e) {
            return false;
        }

    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public String getSenha() {
        return senha;
    }

    public void setSenha(String senha) {
        this.senha = senha;
    }

    public String getDriver() {
        return driver;
    }

    public void setDriver(String driver) {
        this.driver = driver;
    }

    public Connection getConexao() {
        return conexao;
    }

    public void setConexao(Connection conexao) {
        this.conexao = conexao;
    }

}
